function droplinemenu(current){
	$('#main-nav > li').hover(function(){
		$('#main-nav .active').removeClass('active');
		$('#main-nav .border-none').removeClass('border-none');
		$(this).addClass('active');
		$(this).next().addClass('border-none');
	},function(){
		$('#main-nav .active').removeClass('active');
		$('#main-nav .border-none').removeClass('border-none');
		current.addClass('active');
		current.next().addClass('border-none');
	});
}
$(document).ready(function () {
    $('.slider ul').cycle({
        cleartype: !$.support.opacity,
        fx: 'fade',
        speed: '500',
        timeout: 5000,
        random: 1, // random slide
        pause: 1,
        next: '#next',
        prev: '#prev'
    });
});
$(document).ready(function ($) {
    $(".infield label").inFieldLabels();
    $(".close").click(function () {
        $('.toptoday').hide();
    })

    $('#slider-code').tinycarousel({ interval: true, display: 1 });
});
$(document).ready(function($) {
	//tat thong báo admin
	$('.close').click(function(){
		$(this).parent().remove();
	})
    //fix last chid
    $("ul li:last-child").addClass("last");
    $("ul li:first-child").addClass("first");
    //transform
    var current=$('#main-nav .active');
    current.next().addClass('border-none');
	droplinemenu(current);
    
});
$(document).ready(function () {
    //Tooltips
    $(".tip_trigger").hover(function () {
        tip = $(this).find('.tip');
        tip.show(); //Show tooltip
    }, function () {
        tip.hide(); //Hide tooltip		  
    }).mousemove(function (e) {
        var mousex = e.pageX + 20; //Get X coodrinates
        var mousey = e.pageY + 20; //Get Y coordinates
        var tipWidth = tip.width(); //Find width of tooltip
        var tipHeight = tip.height(); //Find height of tooltip

        //Distance of element from the right edge of viewport
        var tipVisX = $(window).width() - (mousex + tipWidth);
        //Distance of element from the bottom of viewport
        var tipVisY = $(window).height() - (mousey + tipHeight);

        if (tipVisX < 20) { //If tooltip exceeds the X coordinate of viewport
            mousex = e.pageX - tipWidth - 20;
        } if (tipVisY < 20) { //If tooltip exceeds the Y coordinate of viewport
            mousey = e.pageY - tipHeight - 20;
        }
        tip.css({ top: mousey, left: mousex });
    });
});
